// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ChangePasswordAction.java

package com.boci.clientapp.authentication.action;

import com.boci.clientapp.authentication.ChangePasswordDialog;
import com.boci.clientapp.authentication.LoginPanel;
import com.boci.clientapp.authentication.handler.LoginHandler;
import com.boci.clientapp.authentication.vo.LoginVO;
import com.boci.clientapp.main.*;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.handler.StaticConnectionParam;
import com.boci.common.util.*;
import java.util.HashMap;
import java.util.logging.Logger;

public class ChangePasswordAction extends AbstractAction
{

    public ChangePasswordAction()
    {
    }

    private void addExtraValues(HashMap pInpMap)
    {
        pInpMap.put("Submit", "Submit");
        pInpMap.put("chgPassword", "Y");
        pInpMap.put("login", ApplicationService.getInstance().getUserID());
        pInpMap.put("channel", "TRADEXPRESS");
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.getChangePasswordDialog().setBusy(true);
	        if(pActionType.equals("CHANGE_PASSWORD_ACTION"))
	        {
	            String strNewPass = (String)pInpMap.get("newPassword");
	            addExtraValues(pInpMap);
	            LoginHandler loginHandler = new LoginHandler(RequestTypeConst.BOCI_CHG_PWD_URL);
	            LoginVO loginVO = (LoginVO)loginHandler.changePassword(pInpMap);
	            if(appServ.isRelogin())
	                appServ.login(appServ.getUserID(), strNewPass, loginVO);
	            else
	                appServ.chgPassword(strNewPass, loginVO);
	            appServ.showChgPassDialog(false);
	            StaticConnectionParam.getInstance().setStrEncPass(loginHandler.getNewEncPasswd());
	            String strNote = ClientAppLoader.getMessagesConfigurator().getUIMessages("CHANGE_PASS.CHANGED_NOTE", appServ.getCurrentLocale());
	            appServ.showInfoDialog(null, strNote);
	            if(appServ.getMainPanel().getLoginPanel().isVisible())
	                appServ.getMainPanel().showLoginPanel(false);
	        } else
	        if(pActionType.equals("CANCEL_ACTION"))
	        {
	            appServ.showChgPassDialog(false);
	            if(appServ.getMainPanel().getLoginPanel().isVisible())
	                appServ.getMainPanel().getLoginPanel().refresh();
	        }
    	}
	    catch(AppException appEx){
	    	logger.info(StringUtil.formatException(appEx));
	    	appServ.showErrorDialog(null, appEx.getMessage());
	    }
	    catch(Exception sysEx){
	    	logger.info(StringUtil.formatException(sysEx));
	    	appServ.showErrorDialog(null, sysEx.getMessage());
	    }finally{
	    	appServ.getChangePasswordDialog().setBusy(false);
	    }
	    return;
    }
}
